package com.mengdie.shuidi.ui.adapter;

import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mengdie.shuidi.R;
import com.mengdie.shuidi.model.ExceedUserEnetity;

import java.util.List;

/**
 * 作者：HQY on 16/11/2 16:29
 * 邮箱：hqy_xz@126.com
 */

public class CoilAdapter extends BaseQuickAdapter<ExceedUserEnetity,BaseViewHolder> {
    private String types;

    public CoilAdapter(List data, String type) {
        super(R.layout.item_coil, data);
        this.types = type;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ExceedUserEnetity coil) {

        if (types.equals("2")) {
            if (baseViewHolder.getAdapterPosition() == 0) {
                baseViewHolder.setText(R.id.tv_item_ip, "IP  " + coil.getLogin_ip())
                        .addOnClickListener(R.id.tv_item_coil);

                if (types.equals("2")) {
                    baseViewHolder.getView(R.id.tv_item_coil).setVisibility(View.GONE);
                    baseViewHolder.getView(R.id.tv_local).setVisibility(View.VISIBLE);
                } else {
                    baseViewHolder.getView(R.id.tv_item_coil).setVisibility(View.VISIBLE);
                    baseViewHolder.getView(R.id.tv_local).setVisibility(View.GONE);
                }
                if (coil.getPlatform().equals("pc")) {
                    Glide.with(mContext)
                            .load(R.drawable.coil_pc)
                            .into((ImageView) baseViewHolder.getView(R.id.iv_item_plat));
                } else {
                    Glide.with(mContext)
                            .load(R.drawable.coil_phone)
                            .into((ImageView) baseViewHolder.getView(R.id.iv_item_plat));
                }
            }
        } else {
            baseViewHolder.setText(R.id.tv_item_ip, "IP  " + coil.getLogin_ip())
                    .addOnClickListener(R.id.tv_item_coil);
            baseViewHolder.getView(R.id.tv_item_coil).setVisibility(View.VISIBLE);
            if (coil.getPlatform().equals("pc")) {
                Glide.with(mContext)
                        .load(R.drawable.coil_pc)
                        .into((ImageView) baseViewHolder.getView(R.id.iv_item_plat));
            } else {
                Glide.with(mContext)
                        .load(R.drawable.coil_phone)
                        .into((ImageView) baseViewHolder.getView(R.id.iv_item_plat));
            }
        }
    }
}
